package pers.xuehongyan.useat.server.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import pers.xuehongyan.useat.server.enity.Machine;
import pers.xuehongyan.useat.server.service.MachineService;

import javax.annotation.Resource;

/**
 * @author xuehongyan
 */
@RestController
@CrossOrigin(origins = {"*", "null"})
@RequestMapping("/machine")
public class MachineController {
    @Resource
    MachineService machineService;

    @PostMapping("/")
    public ResponseEntity<Void> create(
            @RequestParam("capacity") Integer capacity
    ) {
        Machine machine = new Machine(capacity);
        machineService.createMachine(machine);
        return ResponseEntity.status(HttpStatus.CREATED).build();
    }
}
